<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .box1{
            width: 500px;
            height: 500px;
            border: 10px red solid;
            display: grid;

            /*
                justify-items
                    - 设置网格中元素水平方向的对齐方式
                align-items
                    - 设置网格中元素垂直方向的对齐方式
            */
            justify-items: center;
            align-items: center;
        }

        .box2{
            width: 100px;
            height: 100px;
            background-color: #bfa;
        }
    </style>
</head>
<body>
<div class="box1">
    <div class="box2"></div>
</div>
</body>
</html>